import request from '@/router/axios';

export const getList = (current, size, params) => {
  return request({
    url: '/api/mes-product/product/line/page',
    method: 'get',
    params: {
      ...params,
      current,
      size
    }
  });
};

export const getDetail = (id) => {
  return request({
    url: '/api/mes-product/product/line/detail',
    method: 'get',
    params: {
      id
    }
  });
};

export const remove = (ids) => {
  return request({
    url: '/api/mes-product/product/line/remove',
    method: 'post',
    params: {
      ids
    }
  });
};

export const add = (row) => {
  return request({
    url: '/api/mes-product/product/line/submit',
    method: 'post',
    data: row
  });
};

export const update = (row) => {
  return request({
    url: '/api/mes-product/product/line/submit',
    method: 'post',
    data: row
  });
};

// 验证产线是否在生产
export const checkLine = (id) => {
  return request({
    url: '/api/mes-product/productionline/check-line',
    method: 'post',
    params: {
      id
    }
  });
};

// 查询产线下所有可生产的产品
export const getListLineproducts = (lineId) => {
  return request({
    url: '/api/mes-product/productionline/list-line-products',
    method: 'get',
    params: {
      lineId
    }
  });
};

// 配置产线可生产的产品
export const addLineproducts = (data) => {
  return request({
    url: '/api/mes-product/productionline/add-line-products',
    method: 'post',
    data: data
  });
};

// 删除产线可生产的产品
export const removeLineproducts = (data) => {
  return request({
    url: '/api/mes-product/productionline/remove-line-products',
    method: 'post',
    data
  });
};

// 根据产线Id查询产线变更记录
export const queryLineRecord = (lineId) => {
  return request({
    url: '/api/mes-product/productionline/query-line-record',
    method: 'get',
    params: { lineId }
  });
};

// 根据产品Id变更产线状态
export const changeLineRecord = (data) => {
  return request({
    url: '/api/mes-product/productionline/change-line-record',
    method: 'post',
    data
  });
};

// 查询产线列表
export const getAllLineList = () => {
  return request({
    url: '/api/mes-product/productionline/list',
    method: 'get'
  });
};

// 分页查询产线变更记录
export const LineRecordPage = (current, size, params) => {
  return request({
    url: '/api/mes-product/productionline/page-line-records',
    method: 'get',
    params: {
      ...params,
      current,
      size
    }
  });
};

// 根据产品Id获取产品下的工艺路线
export const getProcessRoute = (partNo) => {
  return request({
    url: '/api/mes-product/process/product-route/find-by-part-no',
    method: 'get',
    params: { partNo }
  });
};
